package com.powernobug.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @Author: 肖云戈
 * @CreateTime: 2024-08-30
 * @Description:
 */
public class SyncSubmitUtil {
    private SyncSubmitUtil() {}

    public static  Map<String, Object> syncSubmitTaskToMap(String[] keyArray, List<Future> taskList) {
        Map<String, Object> result = new HashMap<>();

        try {
            for (int i = 0; i < keyArray.length; i++)
                result.put( keyArray[i], taskList.get(i).get());
        } catch (InterruptedException | ExecutionException e) {
            System.out.println("线程操作异常！");
            e.printStackTrace();
            throw new RuntimeException(e);
        }

        return result;
    }
}
